package com.zh.amqp.rabbit;

import com.zh.amqp.rabbit.mqmsg.MsgProducer;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.UUID;

/**
 * @author ZH
 * @date 20:46 2021/4/14
 */
@AllArgsConstructor
@RestController
public class HelloController {
    private MsgProducer msgProducer;

    @GetMapping("/make/date")
    public String makeMsgDate(){
        msgProducer.sendMsg("现在datetime是"+ LocalDateTime.now());
        msgProducer.sendMsg("现在日期是"+ LocalDate.now());
        msgProducer.sendMsg("现在时间是"+ LocalTime.now());
        msgProducer.sendMsg("现在时间戳是"+ Instant.now().toString());
        return "ok "+UUID.randomUUID();
    }

    @GetMapping("/make/number")
    public String makeMsgNumber(@RequestParam Integer count){
        for (int i=1;i<=count;i++){
            msgProducer.sendMsg("我是数字"+ i);
        }
        return "ok "+UUID.randomUUID();
    }

}
